package tr.edu.yildiz.basevaadin.service.impl;

import javax.servlet.ServletException;

import org.osgi.service.http.HttpService;
import org.osgi.service.http.NamespaceException;

import com.vaadin.ui.Component;

import tr.edu.yildiz.basevaadin.service.ServletService;
import tr.edu.yildiz.basevaadin.servlet.BaseVaadinServlet;
import tr.edu.yildiz.dynaView.service.ModuleService;

public class ServletServiceImpl implements ServletService {
	
	ModuleService<Component> moduleService;
	final static String CONTEXT_PATH =  "/VAADIN";
	
	public void registerServlet(HttpService httpService) {
		try {
			httpService.registerServlet(CONTEXT_PATH, new BaseVaadinServlet(moduleService), null, null);
		} catch (ServletException e) {
			e.printStackTrace();
		} catch (NamespaceException e) {
			e.printStackTrace();
		}
	}

	public void unRegisterServlet(HttpService httpService) {
		httpService.unregister(CONTEXT_PATH);
	}
	
	public void setModuleService(ModuleService moduleService) {
		this.moduleService = moduleService;
	}
	
	public void unSetModuleService(ModuleService moduleService) {
		
	}

}
